package lx;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

/* 班级里有N个学生
       要求：
       70%的概率随机到男生
       30%的概率随机到女生

       "范闲","范建","范统","杜子腾","宋合泛","侯笼藤","朱益群","朱穆朗玛峰",
       "杜琦燕","袁明媛","李猜","田蜜蜜",
       */
public class demo2 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        //添加数据
        Collections.addAll(list, 1, 1, 1, 1, 1, 1, 1);
        Collections.addAll(list, 0, 0, 0);
        //打乱集合顺序
        Collections.shuffle(list);
        //随机在集合里抽取一个数,通过这个数是0还是1判断男女
        Random r = new Random();
        int index = r.nextInt(list.size());
        int number = list.get(index);
        //创建一个存储男生名字的集合
        ArrayList<String> Boys = new ArrayList<>();
        Collections.addAll(Boys, "范闲", "范建", "范统", "杜子腾", "宋合泛", "侯笼藤", "朱益群", "朱穆朗玛峰");
        //创建一个存储女生名字的集合
        ArrayList<String> Girls = new ArrayList<>();
        Collections.addAll(Girls, "杜琦燕", "袁明媛", "李猜", "田蜜蜜");
        //根据number来随机男生还是女生里面集合的数据
        if (number == 1) {
            int boyIndex = r.nextInt(Boys.size());
            System.out.println(Boys.get(boyIndex));
        } else {
            int girIndex = r.nextInt(Girls.size());
            System.out.println(Girls.get(girIndex));
        }

    }
}
